<%--
  Created by IntelliJ IDEA.
  User: 罗蔚
  Date: 2022/4/3
  Time: 16:50
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>

    <link rel="stylesheet" href="../font-awesome-4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/login.min.css">
    <script src="../js/jquery-3.6.0.min.js"></script>
    <script src="../js/bootstrap.bundle.min.js"></script>

</head>

<body id="body">
<div id="to-top" class="back-to-top-hidden"><a href="#top" class="fa fa-angle-up"></a></div>
<header>

    <div class="head">
        <a href="${pageContext.request.contextPath}/pages/"><img src="../img/logo.png" alt=""></a>
    </div>

</header>
<div class="banner">
    <div class="login">
        <ul class="clearfix">
            <li>用户名：<input type="text" id="username" name="username" placeholder="请输入用户名"></li>
            <li>密码：<input type="password" id="password" name="password" placeholder="请输入密码"></li>
        </ul>
        <div class="message">${msg }</div>
        <button type="submit">登&nbsp;&nbsp;&nbsp; 录</button>
        <span><a href="${pageContext.request.contextPath}/pages/regist.jsp">免费注册</a></span>
    </div>
</div>

<footer>
    <div class="footer-inner">
        <div class="module">
            <div class="module-head">购物指南</div>
            <ul>
                <li><a href="#">订单状态</a></li>
                <li><a href="#">订单状态</a></li>
            </ul>
        </div>
        <div class="module">
            <div class="module-head">支付帮助</div>
            <ul>
                <li><a href="#">支付帮助</a></li>
                <li><a href="#">在线支付</a></li>
                <li><a href="#">货到付款</a></li>
            </ul>
        </div>
        <div class="module">
            <div class="module-head">配送帮助</div>
            <ul>
                <li><a href="#">EMS/邮政普包</a></li>
                <li><a href="#">商品验货与签收</a></li>
                <li><a href="#">配送范围及运费</a></li>
            </ul>
        </div>
        <div class="module">
            <div class="module-head">售后服务</div>
            <ul>
                <li><a href="#">售后服务</a></li>
                <li><a href="#">发票制度</a></li>
                <li><a href="#">退货说明</a></li>
                <li><a href="#">换货说明</a></li>
            </ul>
        </div>
        <div class="module">
            <div class="module-head">帮助信息</div>
            <ul>
                <li><a href="#">友情链接</a></li>
                <li><a href="#">联系客服</a></li>
                <li><a href="#">找回密码</a></li>
                <li><a href="#">关于我们</a></li>
            </ul>
        </div>
    </div>
    <div class="footer-list">
        <ul>
            <li><a href="#">关于我们</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">常见问题</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">安全交易</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">购买流程</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">如何付款</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">联系我们</a></li>
            <li>
                <div></div>
            </li>
            <li><a href="#">合作提案</a></li>
        </ul>
        <div class="last">Copyright @ 2015-2021 蜀ICP备01000010号</div>
    </div>
</footer>
</body>
<script>

    $("button").click(function () {
        var username = $("#username").val();
        var password = $("#password").val();
        if (username == '' || password == '') {
            $(".message").html("用户名或者密码不能为空")
        } else {
            $(".message").html("")
            $.ajax({
                type: "post",
                url: "${pageContext.request.contextPath}/loginController/login",
                contentType: "application/json",
                data: JSON.stringify({"username": username, "password": password}),
                dataType: "json",
                success: function (data) {
                    // console.log(data);
                    //console.log(data.code+"..."+data.data.username);
                    if (data.code == 500) {
                        $(".message").html("用户名或密码错误，或账号未激活")
                    } else if (data.code == 200) {
                        //alert("跳转到展示列表")
                        location.href = "${pageContext.request.contextPath}/pages/alluser.jsp";
                    }
                }
            })
        }


    })

</script>
</html>